#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
using ull = unsigned long long;
int n, m, q, k, u, v, o[200009], l, oo[100009], ool, tot; ull ko[100009], ban; ll dp[100009][5], dq[5];
bool key[100009]; vector < int > g[100009], t[100009], vt[100009]; vector < pair < int, int > > mdf[59];
namespace TOPO
{
	int deg[100009], d[100009], fa[19][100009], f[100009], o[100009]; queue < int > q; vector < int > gr[100009];
	inline int lca(int u, int v)
	{
		if ( d[u] > d[v] ) swap(u, v);
		Fol(i, 18, 0) if ( d[fa[i][v]] >= d[u] ) v = fa[i][v];
		if ( u == v ) return u;
		Fol(i, 18, 0) if ( fa[i][u] != fa[i][v] ) u = fa[i][u], v = fa[i][v];
		return fa[0][u];
	}
	inline int kth(int u, int k) { Fol(i, 18, 0) if ( k & ( 1 << i ) ) u = fa[i][u]; return u; }
	inline int calc(int u, int v) { v = kth(u, d[u] - d[v] - 1); return d[v] > d[o[u]] ? v : o[u]; }
	inline void work()
	{
		For(i, 1, n) for ( int j : g[i] ) deg[j]++, gr[j].push_back(i);
		for ( o[1] = 1, q.push(1) ; q.size() ; )
		{
			u = q.front(), q.pop(), d[u] = d[fa[0][u]] + 1;
			For(i, 1, 18) fa[i][u] = fa[i - 1][fa[i - 1][u]];
			if ( (int)gr[u].size() > 1 )
			{
				o[u] = u, v = gr[u][0];
				For(i, 1, (int)gr[u].size() - 1)
				{
					v = lca(v, gr[u][i]);
					if ( v != gr[u][i] ) mdf[tot].emplace_back(calc(gr[u][i], v), gr[u][i]);
				}
				if ( v != gr[u][0] ) mdf[tot].emplace_back(calc(gr[u][0], v), gr[u][0]);
				ko[u] |= 1ull << tot++, t[f[u] = v].push_back(u);
			}
			else if ( gr[u].size() ) o[u] = o[gr[u][0]], t[f[u] = gr[u][0]].push_back(u);
			for ( int i : g[u] ) { ko[i] |= ko[u]; if ( !--deg[i] ) fa[0][i] = u, q.push(i); }
		}
	}
}
namespace HLD
{
	int fa[100009], h[100009], sz[100009], hs[100009], tp[100009], dfn[100009], seq[100009], cnt;
	inline void dfs(int u, int fa = 0)
	{
		HLD::fa[u] = fa, h[u] = h[fa] + 1, sz[u] = 1;
		for ( int i : t[u] )
		{
			dfs(i, u), sz[u] += sz[i];
			if ( sz[i] > sz[hs[u]] ) hs[u] = i;
		}
	}
	inline void dfs2(int u, int tp)
	{
		HLD::tp[u] = tp, seq[dfn[u] = ++cnt] = u;
		if ( hs[u] ) dfs2(hs[u], tp);
		for ( int i : t[u] ) if ( i != hs[u] ) dfs2(i, i);
	}
	inline int lca(int x, int y)
	{
		while ( tp[x] != tp[y] ) h[tp[x]] > h[tp[y]] ? ( x = fa[tp[x]] ) : ( y = fa[tp[y]] );
		return h[x] < h[y] ? x : y;
	}
	inline int kth(int x, int k)
	{
		while ( h[x] - h[fa[tp[x]]] <= k ) k -= h[x] - h[fa[tp[x]]], x = fa[tp[x]];
		return seq[dfn[x] - k];
	}
}
inline bool dfncmp(int u, int v) { return HLD::dfn[u] < HLD::dfn[v]; }
namespace ST
{
	struct node
	{
		int v, len, lz;
		inline void apply(int x) { v = x ? len : 0, lz = x; }
	}	t[100009 << 2];
	inline int lc(int p) { return p << 1; }
	inline int rc(int p) { return p << 1 | 1; }
	inline int md(int l, int r) { return ( l + r ) >> 1; }
	inline void pu(int p) { t[p].v = t[lc(p)].v + t[rc(p)].v; }
	inline void pd(int p) { if ( ~t[p].lz ) t[lc(p)].apply(t[p].lz), t[rc(p)].apply(t[p].lz), t[p].lz = -1; }
	inline void build(int p, int l, int r)
	{
		t[p].v = t[p].len = r - l + 1, t[p].lz = -1;
		if ( l != r ) build(lc(p), l, md(l, r)), build(rc(p), md(l, r) + 1, r);
	}
	inline void mdf(int p, int l, int r, int lp, int rp, int v)
	{
		if ( l > rp || r < lp ) return;
		if ( lp <= l && r <= rp ) { t[p].apply(v); return; }
		pd(p), mdf(lc(p), l, md(l, r), lp, rp, v), mdf(rc(p), md(l, r) + 1, r, lp, rp, v), pu(p);
	}
	inline int qry(int p, int l, int r, int lp, int rp)
	{
		if ( l > rp || r < lp ) return 0;
		if ( lp <= l && r <= rp ) return t[p].v;
		return pd(p), qry(lc(p), l, md(l, r), lp, rp) + qry(rc(p), md(l, r) + 1, r, lp, rp);
	}
}
inline void dfs(int uu, int fa = 0)
{
	if ( !key[uu] )
	{
		dp[uu][0] = 1;
		for ( int i : vt[uu] )
		{
			dfs(i, uu), copy(dp[uu], dp[uu] + k + 1, dq), fill(dp[uu], dp[uu] + k + 1, 0);
			For(ii, 0, k) For(jj, 0, k - ii) dp[uu][ii + jj] += dq[ii] * dp[i][jj];
		}
	}
	u = uu, v = HLD::kth(u, HLD::h[u] - HLD::h[fa] - 1);
	while ( HLD::tp[u] != HLD::tp[v] )
		dp[uu][1] += ST::qry(1, 1, n, HLD::dfn[HLD::tp[u]], HLD::dfn[u]), u = HLD::fa[HLD::tp[u]];
	dp[uu][1] += ST::qry(1, 1, n, HLD::dfn[v], HLD::dfn[u]);
}
int main()
{
	freopen("lodge.in", "r", stdin), freopen("lodge.out", "w", stdout);
	cin.tie(nullptr) -> sync_with_stdio(false);
	cin >> n >> m >> q;
	For(i, 1, m) cin >> u >> v, g[u].push_back(v);
	TOPO::work(), HLD::dfs(1), HLD::dfs2(1, 1), ST::build(1, 1, n);
	For(i, 0, tot - 1)
	{
		auto mdfs = mdf[i]; mdf[i].clear();
		for ( auto _ : mdfs )
		{
			v = _.first, u = _.second;
			while ( HLD::tp[u] != HLD::tp[v] )
				mdf[i].emplace_back(HLD::dfn[HLD::tp[u]], HLD::dfn[u]), u = HLD::fa[HLD::tp[u]];
			mdf[i].emplace_back(HLD::dfn[v], HLD::dfn[u]);
		}
	}
	For(_, 1, q)
	{
		cin >> k >> l, ban = 0;
		For(i, 1, l) cin >> o[i], key[o[i]] = true, ban |= ko[o[i]];
		For(i, 0, tot - 1) if ( ban & ( 1ull << i ) )
			for ( auto _ : mdf[i] ) ST::mdf(1, 1, n, _.first, _.second, 0);
		copy(o + 1, o + l + 1, oo + 1), ool = l, o[++l] = 1, sort(o + 1, o + l + 1, dfncmp);
		For(i, 1, l - 1) o[l + i] = HLD::lca(o[i], o[i + 1]);
		sort(o + 1, o + l + l, dfncmp), l = unique(o + 1, o + l + l) - o - 1;
		For(i, 1, l) vt[o[i]].clear(), fill(dp[o[i]], dp[o[i]] + k + 1, 0);
		For(i, 2, l) vt[HLD::lca(o[i - 1], o[i])].push_back(o[i]);
		dfs(1), cout << dp[1][k] << '\n';
		For(i, 1, ool) key[oo[i]] = false;
		For(i, 0, tot - 1) if ( ban & ( 1ull << i ) )
			for ( auto _ : mdf[i] ) ST::mdf(1, 1, n, _.first, _.second, 1);
	}
	return 0;
}